{% extends 'layout.html' %}

{% block title %}{{keyword}} - CiLiBaBa{% endblock %}
{% block metas %}
{{block.super}}
<meta name="keywords" content="{{keyword}},磁力链接,CiLiBaBa" />
<meta name="description" content="{{keyword}} magnet links and bittorrent files." />
<meta name="robots" content="noindex,follow">
{% endblock %}

{% block content %}
<div class="container">

    <div class="div-ads" style="margin-top: -10px; ">
    </div>

{% load filters %}
<h4>Found {{result.meta.total_found}} items for {{keyword}} in {{result.meta.time}}s.</h4>
<p>
    <div class="btn-group" role="group">
    {% for x in cats_navs %}
        <a class="btn btn-xs btn-default {% ifequal x.value category%}active{%endifequal%}" href="./?c={{x.value}}&s={{sort}}" rel="nofollow">{{x.name}}
        {% ifnotequal x.name 'All'%} ({{x.num}}){%endifnotequal%}</a>
    {% endfor %}
    </div>
    <div class="pull-right btn-group" role="group">
    {% for x in sort_navs %}
        <a class="btn btn-xs btn-default {% ifequal x.value sort %}active{%endifequal%}" href="./?c={{category}}&s={{x.value}}" rel="nofollow">{{x.name}}</a>
    {% endfor %}
    </div>
</p>
{% if result.items %}
<table class="table">
    {% for x in result.items %}
    <tr><td class="x-item">
        <div>
            <a title="{{x.name}}" class="title" href="{% url 'hash' x.id%}">{{x.name|highlight:words}}</a>
            <span class="ctime">{{x.create_time|timesince}}</span>
        </div>
        <div class="files">
            <ul>
                {% if 'files' in x %}
                    {% for y in x.files %}
                        <li>{{y.path}}  {{y.length|filesizeformat}}</li>
                    {% endfor %}
                        <li>....</li>
                {% else %}
                    <li>{{x.name}}  {{x.length|filesizeformat}}</li>
                {% endif %}
            </ul>
        </div>
        <div class="tail">
            Files: {{x.files|length}} Total size: {{x.length|filesizeformat}}  Total requests: {{x.requests}} Last access time: {{x.last_seen|timesince}}
            {% if x.maybe_fake %}
                <span class="label label-warning">could be FAKE!!!</span>
            {% endif %}
        </div>
    </td></tr>
    {% endfor %}
</table>
{% include 'pagination.html' %}
{% else %}
        Sorry, not found "{{keyword}}" in the DHT network. Please try it later :)
    <div class="recommendation" style="margin-top: 30px;">
        <h4>See what other people search...</h4>
        <p>
        {% for x in keyword_logs.latest|slice:":100" %}
            <a href="{% url 'list' x.keyword '' %}">{{x.keyword}}</a>
        {% endfor %}
        </p>
    </div>

{% endif %}

</div>
{% include 'foot.html' %}
{% endblock %}

{% block scripts %}
{{block.super}}
<script>
{% ifequal p 1 %}
    $.get("{% url 'top_log'%}?type=keyword&keyword={{keyword|urlencode}}");
{% endifequal %}
</script>
{% endblock %}

